package org.gap.jseed;

public abstract class AbstractInjectorHelper {
	
	protected Injector injector;
	private boolean isInit = false;
	
	public void init() {
		if (!isInit) {
			injector = new Injector();
			isInit = true;
		}
	}
	
	@SuppressWarnings("unchecked")
	protected <T> T getInstance(Class<T> type) throws InstantiationException, IllegalAccessException {
		if (!isInit) {
			init();
		}
		Class<T> x = (Class<T>)injector.inject(type);
		T t = (T)x.newInstance();
		return t;
	}
}
